import { createSSRApp, reactive } from "vue";
import App from "./App.vue";
import store from "./store";
import initDayjs from "@/utils/init-dayjs";
import initRoute from "./utils/init-route";

import config from "@/common/config";
import mainInit from "@/common/init/mainInit";
import uiConfig from "@/common/uiconfig/index";

export function createApp() {
  const app = createSSRApp(App);
  initDayjs(app);
  initRoute(app);

  // 定义全局变量
  app.provide("$globalData", {
    pageChannel: {},
  });

  // 配置初始化
  config.init();
  app.provide("$config", config);

  app.use(store);

  // 配置组件库
  uiConfig(app);

  // main 初始化逻辑
  mainInit.init(app);

  return {
    app,
  };
}
